Skip to content

fixed GPU Lidar rendering issue#130

Open
jonyMarino wants to merge 1 commit intomainfrom
IAMAI/GPU-Lidar-render-fix
Open

fixed GPU Lidar rendering issue#130
jonyMarino wants to merge 1 commit intomainfrom
IAMAI/GPU-Lidar-render-fix

Conversation

@jonyMarino
Copy link
Contributor

Fixes: #

About

This PR fixes a critical crash and assertion failure that occurred when using the gpu_cylindrical Lidar sensor type. The issue was traced to a synchronous RHILockBuffer call within the Render Dependency Graph (RDG) execution, which caused deadlocks and validation failures in the Vulkan RHI (specifically FVulkanStagingBuffer::Lock reading beyond allocated sizes).

Key Changes:
Asynchronous Readback: Replaced the blocking RHILockBuffer with FRHIGPUBufferReadback. This decouples the CPU read from the GPU write, preventing render thread stalls.
Ring Buffer Implementation: Implemented a ring buffer pool (size 4) for the readback buffers.
Problem: The Lidar point cloud size is dynamic and changes every frame based on DeltaTime. Using a single readback variable caused race conditions where the Lock() size on the CPU did not match the size of the pending GPU buffer from a previous frame.
Solution: The ring buffer preserves the specific buffer size associated with each enqueued copy, ensuring that when data is read back (N frames later), the size matches exactly what was allocated for that specific frame.
Render Graph Utils: Added missing include for RenderGraphUtils.h to support AddEnqueueCopyPass.

Technical Details:
Old behavior: Synchronous lock causing check(IsInRenderingThread()) or Vulkan validation errors due to size mismatches.
New behavior: LidarIntensitySceneViewExtension now cycles through a pool of readback buffers. It attempts to lock a buffer from a previous frame; if ready, it copies the data to LidarPointCloudData. This ensures safe, non-blocking data transfer.

How Has This Been Tested?

Verified that gpu_cylindrical no longer causes the Unreal Editor to hang or crash with Vulkan RHI.

Screenshots and videos (if appropriate):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant